from pydantic_settings import BaseSettings
from pydantic import Field
from typing import Optional

class Settings(BaseSettings):
    # MySQL配置
    mysql_host: str = Field(..., env="MYSQL_HOST")
    mysql_port: int = Field(3306, env="MYSQL_PORT")
    mysql_user: str = Field(..., env="MYSQL_USER")
    mysql_password: str = Field(..., env="MYSQL_PASSWORD")
    mysql_db_user: str = Field(..., env="MYSQL_DB_USER")
    mysql_db_friend: str = Field(..., env="MYSQL_DB_FRIEND")
    
    # 服务地址
    user_service_url: str = Field("http://localhost:8001", env="USER_SERVICE_URL")
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"

# 单例配置对象
settings = Settings()
